package com.yanqu.road.server.cmd.activity.recallplayer;


import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.RecallPlayerProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.recallplayer.RecallPlayerModule;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

@Cmd(code = GameProtocol.S_RECALL_PLAYER_CHOOSE_BIG_REWARD, desc = "汴梁达人玩家选择想抽的大奖")
public class RecallPlayerChooseBigRewardCmd extends AbstractCommand {
    private String reward;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        RecallPlayerProto.UserChooseBigRewardReqMsg msg = RecallPlayerProto.UserChooseBigRewardReqMsg.parseFrom(packet.getBytes());
        reward = msg.getRewards();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ret = player.getModule(RecallPlayerModule.class).chooseBigReward(reward);
    }

    @Override
    public void sendData(GamePlayer player) {
        if (ret != 0) {
            RecallPlayerProto.UserChooseBigRewardRespMsg.Builder builder = RecallPlayerProto.UserChooseBigRewardRespMsg.newBuilder();
            builder.setRet(ret);
            player.sendPacket(ClientProtocol.U_RECALL_PLAYER_CHOOSE_BIG_REWARD, builder);
        }
    }
}
